/*
* Copyright © Shanghai Awinic Technology Co., Ltd. 2020-2020. All rights reserved.
* Description: The header file of the wdt related driver library.
* Date： 20201126
* Awinic_Version： aw_soc_driver_v1.0.0
*/
#include "compile_option.h"
#ifdef AW_86802

#ifndef __AW8680X_WDT_H
#define __AW8680X_WDT_H

/* Include ------------------------------------------------------------------*/
#include "aw8680x_def.h"

/**
 * @brief  WDT interrupt mode enumeration
**/
enum wdt_mode_enum
{
	WDT_IRQ_MODE_EN = (AW_U32)0x00000002,
	WDT_IRQ_MODE_DIS = (AW_U32)0x00000000,
};
typedef enum wdt_mode_enum WDT_MODE_TYPE_E;

/**
 * @brief  WDT Initialization Configuration Structure definition
**/
struct wdt_init_struct {
	WDT_MODE_TYPE_E wdt_mode_e;		// Watchdog mode
	AW_U32 wdt_torr;				// Watchdog Timeout range
};
typedef struct wdt_init_struct WDT_INIT_TYPE_S;

/**
 * @brief  WDT Configuration Structure definition
**/
struct wdt_handle_struct {
	IRQn_Type wdt_irq_e;			// WDT irq number
	IRQ_PRI_E wdt_irq_pri_e;		// WDT irq priority
	WDT_INIT_TYPE_S init_s;			// WDT init struct
	WDT_TYPE_S *p_instance_s;		// WDT registers base address
};
typedef struct wdt_handle_struct WDT_HANDLE_TYPE_S;

/* WDT Instances */
#define WDT_CHECK_INSTANCE(instance) (((instance) == WDT0) || ((instance) == WDT1))

#define WDT_CRR_NUM			((AW_U32)0x76)
#define WDT_EN				((AW_U32)0x00000001)

RET_STATUS_E wdt_set_time(WDT_TYPE_S *p_instance_s, AW_U8 set_time);
RET_STATUS_E wdt_reset(WDT_HANDLE_TYPE_S *p_wdt_lib);
RET_STATUS_E wdt_clean_irq(WDT_HANDLE_TYPE_S *p_wdt_lib);
RET_STATUS_E wdt_init(WDT_HANDLE_TYPE_S *p_wdt_lib);
RET_STATUS_E wdt_irq(WDT_HANDLE_TYPE_S *p_wdt_lib);
void wdt0_irq_call(WDT_HANDLE_TYPE_S *p_wdt_lib);
void wdt1_irq_call(WDT_HANDLE_TYPE_S *p_wdt_lib);

#endif
#endif
